<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div01{
				width: 50px;
				height: 50px;
				position: absolute;
				background-color: #40E0D0;
				
				
			}
		</style>
	</head>
	<body>
		<div id="div01">
			
		</div>
		<script type="text/javascript">
			var moving=false
			var posX
			var posY
			div01.onmousedown=function(){
				moving=true
				posX=div01.offsetLeft-event.clientX
				posX=div01.offsetTop-event.clientY
			}
			div01.onmousemove=function(){
				if(moving){
			div01.style.left=event.clientX+"px";
			div01.style.top=event.clientY+"px";
			}
			}
			div01.onmouseup=function(){
				moving=false
			}
		</script>
	</body>
</html>
